package com.guo.hui.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guo.hui.dao.ponal.CateDataMapper;
import com.guo.hui.enumtype.DelFlag;
import com.guo.hui.model.ponal.CateData;
import com.guo.hui.page.PageParam;
import com.guo.hui.service.ResumeCateDataService;
import com.guo.hui.util.UtilDate;

@Service("resumeCateDataService")
public class ResumeCateDataServiceImpl implements ResumeCateDataService {

	@Autowired
	private CateDataMapper cateDataDao;

	@Override
	public void saveCateData(CateData cateData) {
		String time = UtilDate.datetoString(new Date(), "yyyy-MM-dd");// 日期转化字符串
		cateData.setCreateDate(time);
		cateData.setDelflag(DelFlag.AVIABLE.toString());
		cateData.setModifyDate(new Date());
		cateDataDao.insert(cateData);

	}

	@Override
	public void updateCateData(CateData cateData) {
		cateData.setModifyDate(new Date());
		cateDataDao.update(cateData);
	}

	@Override
	public PageInfo<CateData> selectByMapPage(PageParam pageParm) {
		PageHelper.startPage(pageParm.getPage(), pageParm.getPageSize());
		List<CateData> list = cateDataDao.selectByMap(pageParm.getSearchContent());
		return new PageInfo<CateData>(list);
	}

}
